﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BgScaler : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        RectTransform rt = this.GetComponent<RectTransform>();
        RectTransform prt = this.transform.parent.GetComponent<RectTransform>();
        float width = rt.rect.width;
        float height = rt.rect.height;
        float pWidth = prt.rect.width;
        float pHeight = prt.rect.height;
        float scale = Mathf.Max(pWidth/width, pHeight/height);
        rt.localScale = new Vector3(scale,scale, scale);
    }
}
